package cn.zysheep;

import cn.zysheep.exception.ExceptionUtil;
import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/17
 */
@EnableFeignClients(basePackages = "cn.zysheep.feign")
@EnableDiscoveryClient
@SpringBootApplication
public class ProductServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProductServiceApplication.class,args);
    }

    @Bean
    @LoadBalanced
    @SentinelRestTemplate(fallback = "handleFallback",fallbackClass = ExceptionUtil.class,
            blockHandler = "handleBlock", blockHandlerClass = ExceptionUtil.class)
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
